<?php
if (!defined('IN_XLP')) {
    exit('Access Denied');
}
$Document = array(
    'pageid' => 'notice-index', //页面标示
    'pagename' => '通知列表', //当前页面名称
    'mycss' => array(), //加载的css样式表
    'myjs' => array(), //加载的js脚本
	'footerjs'=>array('content/jquery.smoothConfirm'),
    'head' => true, //加载头部文件
);

include getTpl('header', 'public');
?>
<!--顶部导航 开始-->
<?php include getTpl('top', 'public');?>
<!--顶部导航 结束-->
<!--左侧菜单 开始-->
<?php include getTpl('nav', 'public');?>
<!--左侧菜单 结束-->
<!--主体 开始-->
<!-- content -->

<section id="content" class="main-section"> 
  <!-- main padder -->
  <section class="main padder">
    <div class="clearfix">
      <h4><i class="fa fa-table"></i><?php echo trim($Document['pagename'],'_');?></h4>
    </div>
    <div class="row"> 
      
      <!-- table 11 -->
      <div class="col-lg-12">
		<div class="block">
        	<a class="btn btn-default" href="<?php echo U('notice/add');?>">发布通知</a>
          	<div class="btn-group" style="margin-left:20px">
            	<a class="btn btn-white" href="<?php echo U('notice/index',array('act'=>'all','type'=>0));?>">全部通知</a>
                <?php foreach($noticeType as $key=>$val){?>
            	<a class="btn btn-white" href="<?php echo U('notice/index',array('act'=>'one','type'=>($key+1)));?>"><?php echo $val;?></a>
				<?php }?>
          	</div>
		</div>
        <section class="panel">
          <div class="table-responsive">
            <table class="table table-striped b-t text-small">
              <thead>
                <tr>
                  <th align="center">ID</th>
                  <th align="center">类型</th>
                  <th align="center">标题</th>
                  <th align="center">开始时间</th>
                  <th align="center">结束时间</th>
                  <th align="center">发布状态</th>
                  <th align="center">已推送人数</th>
                  <th align="center">发布时间</th>
                  <th align="center">操作</th>
                </tr>
              </thead>
              <tbody>
                <?php
                    if ($rs){
                       foreach($rs as $val){
                 ?>
                <tr id="list_detail_<?php echo $val['nid'];?>">
                  <td><?php echo $val['nid'];?></td>
                  <td><?php echo $noticeType[$val['type']];?></td>
                  <td><a href="<?php echo U('notice/tlist',array('id'=>$val['nid']));?>" target="_blank"><?php echo $val['title'];?></a><?php if($val['is_del']){echo '[<span class="red">素材被删</span>]';}?></td>
                  <td><?php echo ($val['stime']?outTime($val['stime']):'');?></td>
                  <td><?php echo ($val['etime']?outTime($val['etime']):'');?></td>
                  <td id="status_detail_<?php echo $val['nid'];?>"><?php echo $newsStatus[$val['status']];?></td>
                  <td><?php echo $val['counts'];?></td>
                  <td><?php echo ($val['infotime']?outTime($val['infotime']):'');?></td>
                  <td><div class="btn-group">
                      <button class="btn btn-white btn-xs dropdown-toggle" data-toggle="dropdown">操作<span class="caret"></span></button>
                      <ul class="dropdown-menu">
                        <!-- <li><a href="<?php echo U('notice/tlist',array('id'=>$val['nid']));?>" target="_blank">查看</a></li> -->
                        <!-- <li><a href="javascript:;" rel="<?php echo $val['nid'];?>" class="updown">修改状态</a></li> -->
                        <li><a href="javascript:;" rel="<?php echo $val['nid'];?>" class="delete">删除</a></li>
                      </ul>
                    </div></td>
                </tr>
                <?php
                    }
                 }else{
                ?>
                <tr>
                  <td colspan="20" align="center">暂无数据</td>
                </tr>
                <?php
                  }
               ?>
              </tbody>
            </table>
          </div>
          <footer class="panel-footer">
            <div class="row">
              <div class="col-sm-12 text-right text-center-sm"> <?php echo page($total,$p,'',20,'p');?> </div>
            </div>
          </footer>
        </section>
      </div>
      <!--/ table 11 --> 
      
    </div>
  </section>
  <!--/ main padder --> 
</section>
<!--/ content --> 
<!--主体 结束--> 
<script>
$(function(){
	$('.delete').click(function(){
		var id=$(this).attr('rel');
	  $(this).smoothConfirm("确认删除吗？", {
		  ok: function() {
			  Msg.loading();
			  $.post('<?php echo U('notice/delete');?>',{"id":id},function(result){
				  Msg.hide();
				  $("#list_detail_"+id).fadeOut();
			  },'json');
		  },
		  //点击取消返回callback
		  cancel: function() {
			  return false;
		  }
	  });
	  $("body").click();
	  return false;
	});
	$('.updown').click(function(){
		var id=$(this).attr('rel');
	  $(this).smoothConfirm("确认执行操作吗？", {
		  okVal:'推送',
		  cancelVal:'不推送',
		  ok: function() {
			  Msg.loading();
			  $.post('<?php echo U('notice/deal');?>',{"id":id,'do':'up'},function(result){
				  Msg.hide();
				  $("#status_detail_"+id).html('<?php echo $newsStatus[1];?>');
			  },'json');
		  },
		  cancel: function() {
			 $.post('<?php echo U('notice/deal');?>',{"id":id,'do':'down'},function(result){
				  $("#status_detail_"+id).html('<?php echo $newsStatus[0];?>');
			  },'json'); 
		  }
	  });
	  $("body").click();
	  return false;
	})
})
</script>
<?php
include getTpl('footer', 'public');
?>
